系統魔法棒:學用Solaris系統幫助

1.從solaris系統中獲得在線上幫助

  solaris 系統提供了非常豐富的在線上幫助.這些幫助主要以兩種形式存在,一種是命令的參考手冊頁(reference manual pages,也即我們常說的man page),另外一種是answer book,是sun公司的資料的電子版。

  使用solaris在線上幫助的方法:

  a. 使用reference manual page

  在命令行上使用man命令:

  如:$ man ls <enter>

  b. 使用answer book

  在命令行上使用answerbook命令

  如:$ answerbook <enter>

  2. man page的組織

  unix的man page是按照節(section)來組織的.當我們使用man ls的時候,會看到ls(1),這個括弧中的1就表示ls的man page位於section 1。

  section通常是由一個主section名和一個可選的次section名組成.主section名通常是一個數字,次section名通常是一個或多個字母組成.

  solaris中各 section 所對應的內容:

  1: user commands and utilities

  2: system calls

  3: c library functions

  4: file formats

  5: headers,tables and macros

  6: games and demos

  7: device and network interfaces

  8: maintance and accounting commands

  9: device driver interfaces

  3.man page的存放位置

  a.系統本身的 man page存放在/usr/share/man/man*目錄中, /usr/man 是/usr/share/man的一個軟連結.

  註:在安裝作業系統時,man page是可選安裝。如果未安裝,可將其它機器上的/usr/share/man目錄 mount 到本機上。或使用安裝光碟將相應的package裝上。

  b.很多套用軟體有自己的man page.它們的預設的安裝目錄通常是/usr/local/man/man*.通常可以通過修改該軟體的配置檔案來指定新的安裝目錄(只需設定到/some/directory/man 這一層)

  4.設定 man page的搜尋路徑

  當使用man命令查看某個命令或檔案的幫助時,man要根據系統的環境變數manpath的值來確定搜尋的路徑。當manpath變數未設定時,man 命令預設查找/usr/share/man目錄。

  manpath的格式:

  manpath=dir1:dir2:dir3:...dirn; export manpath

  設定manpath的方法

  (1).臨時性修改manpath

  在命令行上輸入以下命令:

  $ manpath=$manpath:/xxx/xxx/man<enter>

  $ export manpath<enter>

  (2).永久性修改manpath

  在用戶自己的 .profile檔案中加入上述兩行內容

  5.man 命令的高級使用技巧

  a.使用 -s 選項明確指定man page的section 號

  如:$ man -s 4 passwd<enter>

  -s 選項非常有用。因為man的搜尋順序是根據man.cf中的設定來進行的。當man找到一個匹配時,就不再往下找了。所以當你想查看一下/etc/passwd檔案的格式而不是想了解passwd命令的使用時,光使用man passwd 你永遠達不到目的。這時使用man -s 4 passwd,強制man只搜尋section 4中的檔案。

  b.使用 -f 選項列出某個命令的全部man page 的一行性摘要

  該用法等同於 whatis 命令註:使用該選項或whatis命令時,要用到man的 windex資料庫。如果沒有windex檔案,可以使用catman -w 來創建該檔案。

  如:$ whatis ls<enter>

  ls ls (1) - list contents of directory

  ls ls (1b) - list the contents of a directory

  c.使用 -k 選項列出一行性摘要中含有給定關鍵字的所有命令

  該用法等同於 apropos 命令

  如:$ apropos shadow<enter>

  lckpwdf lckpwdf (3c) - manipulate shadow password database lock file

  putspent putspent (3c) - write shadow password file entry

  pwconv pwconv (1m) - installs and updates /etc/shadow with information from /etc/passwd

  shadow shadow (4) - shadow password file

  ulckpwdf lckpwdf (3c) - manipulate shadow password database lock file

  d.使用 -d 選項查看man 命令的工作過程

  6. 使用 answer book

  answer book在solaris系統中是作為一個package而組織的,它也是系統的可選安裝.

  使用answer book的方法

  $ answerbook <enter>

  * 如何使用裝在其它機器上的 answer book?

  例如:liszt 上的用戶要使用public主機上的answerbook

  step 1: 在 public 上執行以下命令:

  $ display=liszt:0.0 ; export display <enter>

  step 2: 在 liszt 上執行以下命令:

  $ xhost public <enter>

  step 3: 在 public 上執行answerbook 命令

  $ answerbook <enter>